import { createAndInitilalizeTable } from '@/components/table/lib';
import { ready, assert, getApiPath } from '@/lib/utils.ts';

import {
    IDCol,
    tf,
} from '@/components/table/lib';

function initializeTable(url: string) {
    const table_elem = document.getElementById("table");
    assert(table_elem, "Element with ID 'table' not found");
        
    createAndInitilalizeTable(
        url,
        table_elem,
        {
            columnDefs: [
                IDCol,
                {
                    ...tf("investigation_time", "检查时间"),
                    type: "date"
                },
                {
                    ...tf("unit_personnel", "检查单位及人员"),
                    width: 200,
                },
                {
                    ...tf("problem_rectify", "问题及整改"),
                    minWidth: 200,
                    flex: 1
                },
            ]
        }
    );
}

(function () {
    ready(() => {
        initializeTable(getApiPath());
    });
})();
